Fix Qwen3 MoE identity LoRA export layout#688
Merged
Conversation
Kovbo
approved these changes
May 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes Qwen3 MoE step-0 identity LoRA normalization so the identity adapter is exported in the same per-expert Qwen3 MoE layout as trained checkpoints.
Qwen3 MoE identity adapters are initially created through PEFT target-parameter LoRA, which produces fused expert keys like:
mlp.experts.base_layer.lora_A/Bmlp.experts.lora_A/BART now expands those Qwen3 MoE identity tensors into the vLLM/Megatron-compatible per-expert layout:
mlp.experts.{expert}.gate_proj.lora_A/Bmlp.experts.{expert}.up_proj.lora_A/Bmlp.experts.{expert}.down_proj.lora_A/BThis only adds a Qwen3 MoE
to_vllm_lora_tensorsconversion path. Trained Qwen3 MoE adapters that are already per-expert pass through unchanged.Also adds
expertsto Qwen3 MoE default target modules so vLLM wraps the routed MoEFusedMoElayer, while preservinggate_proj,up_proj, anddown_projfor Megatron's per-expert LoRA wrapping.Validation
uv run --extra megatron --group dev pytest -q tests/integration/megatron/lora/test_lora_disk_codecs.py -k "qwen3_fused_identity or qwen3_dense_and_moe"2 passed, 5 deselectedyes_no_trainabilityworkflow forQwen/Qwen3-30B-A3B-Instruct-25070.50.96875266.91,61.89@0,@1, and@2adapters.0000,0001, and0002use per-expert Qwen3 MoE keys with no fusedbase_layerexpert keys.vllm==0.19.0parser accepts the same per-expert Qwen3 MoE format.